//
//侧滑栏上部分视图
//用户头像、用户名、设置、通知视图


#import "UserPhotoView.h"

//视图的宽度
#define kUserPhotoViewWidth    self.frame.size.width
//视图的高度
#define kUserPhotoViewHight    self.frame.size.height
//头像视图的高度和宽度
#define kPhotoSize  80

@implementation UserPhotoView
{
    //头像视图
    UIImageView *headPhoto;
}
#pragma mark - 初始化子视图
- (void)initSubview
{
 

    //左上角的设置按钮
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn setFrame:CGRectMake(0, 0, 28, 28)];
    [btn setImage:[UIImage imageNamed:@"setup_button.png"] forState:UIControlStateNormal];
    [btn addTarget:self action:@selector(setting) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:btn];
    
    //右上角的通知
    UIButton *notice = [UIButton buttonWithType:UIButtonTypeCustom];
    [notice setFrame:CGRectMake(230, 0, 28, 28)];
    [notice setImage:[UIImage imageNamed:@"setup_button.png"] forState:UIControlStateNormal];
    [notice addTarget:self action:@selector(notice) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:notice];
    
    
    //中部头像视图
    if(headPhoto == nil)
    {
        headPhoto = [[UIImageView alloc] initWithFrame:CGRectMake(98, 30, kPhotoSize, kPhotoSize)];
        
        UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] init];
        [tapGesture addTarget:self action:@selector(pushToInforView)];
        
        headPhoto.layer.cornerRadius = kPhotoSize/2.0;
        
        //开启用户交互
        headPhoto.userInteractionEnabled = YES;
        
        //设置默认头像
        [headPhoto setImage:[UIImage imageNamed:@"heardIcon.png"]];
        
        //添加点击手势
        [headPhoto addGestureRecognizer:tapGesture];
        
        [self addSubview:headPhoto];
    }
    
    //下部昵称设置
    UIButton *nike = [UIButton buttonWithType:UIButtonTypeCustom];
    nike.titleLabel.textAlignment = NSTextAlignmentCenter;
    [nike setFrame:CGRectMake(30, kPhotoSize+35, 220, 14)];
    [nike setTitle:@"昵称" forState:UIControlStateNormal];
    [nike setTintColor:[UIColor whiteColor]];
    [nike setBackgroundColor:[UIColor clearColor]];
    [self addSubview:nike];
    
}
#pragma mark - 跳转到个人设置界面
- (void)pushToInforView
{
    
}
#pragma mark - 通知
- (void)notice
{
    
}
#pragma mark - 设置
- (void)setting
{
    
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
